$(function () {
    var markId = getUrlString('markid');
    var id = getUrlString('id');
    var isApp = getUrlString('isApp');//isApp=1是小程序;
    let topHeight;



    function detail() {
        var data = {
            'toysid':id
        };
        getData('post','/niu/api/niu_gettoysinfo.php',data,function (data) {
            console.log(data);
            $('.toyspic').attr('src',data.pics);
            $('.toysname,.indexName').html(data.name);
            $('#price').html(data.price);
            $('#mainseries').html(data.mainseries);
            $('#maker').html(data.maker);
            $('#secondseries').html(data.secondseries);
            var time = data.book_time.substring(0,4) + '年' + data.book_time.substring(4,6)+'月';

            if (data.book_time === '0'){
                $('.fssj').html('无');
            } else {
                $('.fssj').html(time);
            }
            if (data.sptype === '2'){
                $('.spzt').html('预售商品');

            } else  if (data.sptype === '3'){
                $('.spzt').html('寄售商品');

            } else{
                $('.spzt').html('现货商品')
            }
            $('.commodityPicture').html(escape2Html(data.intro));
            topHeight = $('.commodityPic').height() + 30;
        })
    }
    detail();
    $('#close').click(function () {
        nativeCommand('dancool://activity=fin')
    });

    //判断是否是在小程序
    if (isApp === '1'){
        $('.indexTitleName,#close').hide();
    }else {
        $(window).scroll(function () {
            var top = $(window).scrollTop();//滚动条距离顶部的高度
            if (top > topHeight){
                $('.indexTitleName').fadeIn()
            } else {
                $('.indexTitleName').fadeOut()
            }
        });
    }
});
